import Vue from "vue"
import Router from "vue-router"
import List from "./views/list.vue"
import detail from "./views/detail.vue"
import searchTieba from "./views/searchTieba";
const notice =() => import('./newviews/notice');  //系统通知
const noticedetail =() => import('./newviews/noticedetail');  //系统通知详情
const letter = () => import('./newviews/letter'); // 朋友私信
const letterdetail = () => import('./newviews/letterdetail'); // 朋友私信详情
const newindex = () => import('./newviews/newindex');   //帖子首页
const profile = () => import('./newviews/profile'); //个人主页
const mypost = () => import('./newviews/mypost'); //我的贴子
const mycource = () => import('./newviews/mycource'); //我的课程
const myreply =() => import('./newviews/myreply'); //我的回复
const search =() => import('./newviews/search'); //搜索界面
const discussdetail =() => import('./newviews/discussdetail'); //贴子详情
const followee = () => import('./newviews/followee'); //我关注的人
const follower = () => import('./newviews/follower');  //关注我的人
const content =  () => import('./newviews/discusspost-content');  //数据概览
Vue.use(Router);
//以下代码解决路由地址重复点击的报错问题
const originalPush = Router.prototype.push
   Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
export default new Router({
    mode: "history",
    base: process.env.BASE_URL,
    routes: [
        {
            path: "",
            redirect: "list",
        },
        {
            path: "/list",
            component: List
        }, {
            path: "/detail",
            component: detail
        },
        {
            path: "/searchTieba/:searchMsg",
            component: searchTieba
        },
        {
            path: '/notice',
            component: notice,
            meta: {
                loginRequire: true
            },
        },
        {
            path: '/noticedetail/:topic',
            component: noticedetail,
            meta: {
                loginRequire: true
            },
        },
        {
            path: '/newindex',
            component: newindex
        },
        {
            path: '/profile/:userId',
            component: profile
        },
        {
            path: '/mypost/:userId', //这种后面跟着id的url，不仅仅可以本人看自己的帖子回复，也可以在未登录的情况下看其他人的帖子回复。所以该请求的前端和后端都不拦截未登录的用户。
            component: mypost
        },
        {
            path: '/mycource/:userId', //这种后面跟着id的url，不仅仅可以本人看自己的帖子回复，也可以在未登录的情况下看其他人的帖子回复。所以该请求的前端和后端都不拦截未登录的用户。
            component: mycource
        },
        {
            path: '/myreply/:userId',
            component: myreply
        },
        {
            path: '/letter',
            component: letter,
            meta: {
                loginRequire: true
            },
        },
        {
            path: '/letterdetail/:conversationId',
            component: letterdetail,
            name: 'letterdetail',
            meta: {
                loginRequire: true
            },
        },
        {
            path: '/search/:searchMsg',
            component: search
        },
        {
            path: '/discussdetail/:id',
            component: discussdetail
        },
        {
            path: '/followee/:userId',
            component: followee
        },
        {
            path: '/follower/:userId',
            component: follower
        },
        {
            path: '/discusspost-content',
            component: content,
            meta: {
                loginRequire: true
            },
        }
    ]
})
